﻿Imports DataObject
Imports BusinessObject
Imports Microsoft.ApplicationBlocks.Data

Public Class frmHopDongBanList

    Private oHopDong As New BusHopDong
    Private oPrHopDong As New HopDong
    Private oConn As New hDBase
    Private ds As New DataSet

    Private Sub frmHopDongBanList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        InitData()
        LoadGridView()
        RefreshToolbar()
    End Sub

    Protected Overrides Sub LoadDataGrid()
        Try
            tableDictionary = oHopDong.Get_HopDong_byLoaiHopDong(sConn, 2)
            ListBindingSource.DataSource = tableDictionary
            grdList.DataSource = ListBindingSource
        Catch ex As Exception
            MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Private Sub LoadGridView()
        Try
            grdList.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect
            With grdList.DisplayLayout.Bands(0)
                .Columns("SoHopDong").Hidden = True
                .Columns("ChucVu").Hidden = True
                .Columns("GiaTriHD").Hidden = True
                .Columns("SoLoaiTien").Hidden = True
                .Columns("SoDoiTuong").Hidden = True
                .Columns("SoTinhTrangHD").Hidden = True
                .Columns("LyDoKetThuc").Hidden = True
                .Columns("LoaiHopDong").Hidden = True
                .Columns("NguoiKy").Hidden = True


                .Columns("MaHopDong").Header.Caption = "Số hợp đồng"
                .Columns("NgayKy").Header.Caption = "Ngày ký hợp đồng"
                .Columns("NgayHieuLuc").Header.Caption = "Ngày hiệu lực"
                .Columns("NgayKetThuc").Header.Caption = "Ngày kết thúc"


                .Columns("MaHopDong").Header.VisiblePosition = 1
                .Columns("NgayKy").Header.VisiblePosition = 2
                .Columns("NgayHieuLuc").Header.VisiblePosition = 3
                .Columns("NgayKetThuc").Header.VisiblePosition = 4
            End With

        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try

    End Sub

    Protected Overrides Sub InitAddNewRow(ByVal oRow As System.Data.DataRow)
        With oRow
            .Item("MaHopDong") = ""
        End With
    End Sub

    Protected Overrides Function DeleteDictionary() As Boolean
        oPrHopDong.SoHopDong = iValue
        oHopDong.DeleteHopDong(sConn, oPrHopDong)
    End Function

    Private Sub grdList_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles grdList.MouseClick
        Try
            iValue = grdList.ActiveRow.Cells(TablePrimaryKey).Value
        Catch ex As Exception
        End Try
    End Sub

End Class
